package cn.ultrarisk.scadmin.manager.biz.solr.dto;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * CollectionAnalyzer
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/6/8
 * @since V1.0
 */
public class CollectionAnalyzer implements Serializable {
    private static final long serialVersionUID = 1623094600695449287L;

    private String type;
    private String name;
    private String value;
    private Boolean query;
    private Boolean index;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getQuery() {
        return query;
    }

    public void setQuery(Boolean query) {
        this.query = query;
    }

    public Boolean getIndex() {
        return index;
    }

    public void setIndex(Boolean index) {
        this.index = index;
    }

    public Map<String, Object> getParams() {
        Map<String, Object> querys = new LinkedHashMap<String, Object>();

        querys.put("wt", "json");
        querys.put("analysis.showmatch", true);
        if ("type".equals(type)) {
            querys.put("analysis.fieldtype", name);
        } else {
            querys.put("analysis.fieldname", name);
        }
        if (query != null && query) {
            querys.put("analysis.query", value);
        }
        if (index != null && index) {
            querys.put("analysis.fieldvalue", value);
        }

        return querys;
    }
}
